#! /bin/bash

set -euE

cat <<'EOF' > $target/etc/systemd/system/sshkeygen.service
[Unit]
Description=ssh host keys generator
After=network.target auditd.service
Before=ssh.service

[Service]
Type=oneshot
ExecStart=ssh-keygen -A                             

[Install]
WantedBy=multi-user.target ssh.service
EOF

ln -s /etc/systemd/system/sshkeygen.service $target/etc/systemd/system/multi-user.target.wants/sshkeygen.service

cat <<'EOF' > $target/etc/ssh/sshd_config.d/additional.conf
PasswordAuthentication yes
PermitEmptyPasswords yes
PermitRootLogin yes
EOF
